home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 1.iso / toolbox / src / exampleCode / opengl / defrasterPort / defi.c < prev    next >
C/C++ Source or Header  |  1996-11-11  |  3KB  |  104 lines

  1. /*
  2.  * Copyright (c) 1994, Silicon Graphics, Inc.
  3.  *
  4.  * Permission to use, copy, modify, distribute, and sell this software and
  5.  * its documentation for any purpose is hereby granted without fee, provided
  6.  * that the name of Silicon Graphics may not be used in any advertising or
  7.  * publicity relating to the software without the specific, prior written
  8.  * permission of Silicon Graphics.
  9.  *
  10.  * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
  11.  * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
  12.  * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
  13.  *
  14.  * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
  15.  * INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER
  16.  * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT ADVISED OF THE
  17.  * POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF LIABILITY, ARISING OUT OF OR IN
  18.  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  19.  *
  20.  * OpenGL(TM) is a trademark of Silicon Graphics, Inc.
  21.  */
  22. /*
  23.  * Example showing how to render a defrasterfont with irisGL
  24.  *
  25.  * Yusuf Attarwala
  26.  *
  27.  * cc defi.c -o defi -lgl
  28.  *
  29.  */
  30.  
  31. #include <gl.h>
  32.  
  33. static int test_width  = 33;
  34. static int test_height = 33;
  35.  
  36. unsigned short      test_raster[] = {
  37.         0x000f, 0xf000, 0x0000,
  38.         0x0010, 0x0800, 0x0000,
  39.         0x0060, 0x0600, 0x0000,
  40.         0x0180, 0x0180, 0x0000,
  41.         0x0600, 0x0060, 0x0000,
  42.         0x0800, 0x0010, 0x0000,
  43.         0x0803, 0xc010, 0x0000,
  44.         0x100f, 0xf008, 0x0000,
  45.         0x1038, 0x1c08, 0x0000,
  46.         0x2060, 0x0604, 0x0000,
  47.         0x2080, 0x0104, 0x0000,
  48.         0x4000, 0x0002, 0x0000,
  49.         0x8000, 0x0001, 0x0000,
  50.         0x8003, 0xc001, 0x0000,
  51.         0x8003, 0xc001, 0x0000,
  52.         0x8001, 0x8001, 0x0000,
  53.         0x8000, 0x0001, 0x0000,
  54.         0x8000, 0x0001, 0x0000,
  55.         0x8070, 0x0e01, 0x0000,
  56.         0x8070, 0x0e01, 0x0000,
  57.         0x8070, 0x0e01, 0x0000,
  58.         0x4070, 0x0e02, 0x0000,
  59.         0x2000, 0x0004, 0x0000,
  60.         0x2000, 0x0004, 0x0000,
  61.         0x1000, 0x0008, 0x0000,
  62.         0x1000, 0x0008, 0x0000,
  63.         0x0800, 0x0010, 0x0000,
  64.         0x0800, 0x0010, 0x0000,
  65.         0x0600, 0x0060, 0x0000,
  66.         0x01ff, 0xff80, 0x0000,
  67.         0x007f, 0xfe00, 0x0000,
  68.         0x001f, 0xf800, 0x0000,
  69.         0x000f, 0xf000, 0x0000};
  70.  
  71. #define EXAMPLEFONT 1
  72. #define efont_nc 100
  73. #define efont_nr (sizeof(test_raster)/sizeof(unsigned short))
  74.  
  75. main()
  76. {
  77.     Fontchar fchar[efont_nc];
  78.  
  79.     prefposition(10,210,10,210);
  80.     winopen("irisGL defraster");
  81.     winconstraints();
  82.  
  83.     color(0);
  84.     clear();
  85.  
  86.     fchar['a'].offset = 0;
  87.     fchar['a'].w      = test_width;
  88.     fchar['a'].h      = test_height;
  89.     fchar['a'].xoff   = 0;
  90.     fchar['a'].yoff   = 0;
  91.     fchar['a'].width  = test_width;
  92.  
  93.     defrasterfont(EXAMPLEFONT,test_height,efont_nc,fchar,efont_nr,test_raster);
  94.     font(EXAMPLEFONT);
  95.  
  96.     ortho2(0.0,200.0,0.0,200.0);
  97.     color(7);
  98.     cmov2i(20,20);
  99.     charstr("a");
  100.  
  101.     sleep(5);
  102.     exit();
  103. }
  104.